package org.alis.smallcc.designpatterns.behavior.observer;

/**
 * 观察者模式
 * @author luochuan
 */
public class PackageInfo {
	
	public static void main(String[] args) {
		// 两个房子 4个人强
		// 先来两个房子
		Observable villa = new VillaObservable();
		Observable apartment = new ApartmentObservable();
		
		// 来3个穷逼
		Observer poorOne = new PoorObserver();
		Observer poorTwo = new PoorObserver();
		Observer poorThree = new PoorObserver();
		
		// 来一个有钱人
		Observer rich = new RichObserver();
		
		// 穷逼都想去买别墅
		villa.register(poorTwo);
		villa.register(rich);
		
		
		// 都想买个公寓拿来用
		apartment.register(poorOne);
		apartment.register(poorTwo);
		apartment.register(poorThree);
		apartment.register(rich);

		// 公寓要传递售楼部的电话
		apartment.setTransmitThis(Boolean.TRUE);
		// 2020年疫情原因 房价开始波动
		villa.notifyObserver();
		apartment.notifyObserver();
		
		
	}
}
